<?php
include 'konek.php';
session_start();
if(!isset($_SESSION['username']))
 {   
?><script language="javascript">alert('anda blm login');
document.location='../'</script><?php 
}
else
{
$username = $_SESSION['username'];
$status = $_SESSION['status'];
}

/*if(!isset($_GET['stat']))
{
	echo "<script>alert('DATA DITAK DITEMUKA');</script";
}
else
{
	$stat=$_GET['stat'];
}*/
if($status=='siswa')
{
	siswa($username,$status);
}
else
{
	guru($username,$status);
}

function guru($user,$stat)
{
$first=$_POST['firstname'];
$last=$_POST['lastname'];
$ttl=$_POST['ttl'];
$mapel=$_POST['mapel'];
$email=$_POST['email'];
$pass=$_POST['password'];
$img=$_POST['image'];
	$syntax=mysql_query(" UPDATE guru set first_name='$first', last_name='$last', ttl='$ttl', mapel='$mapel', email='$email', pass='$pass', img='$img' where email='$user' and pass='$pass' ");

?><script language="javascript">alert('SUKSES');
document.location='../editprofile.php'</script><?php 


}

function siswa($user,$stat)
{
$first=$_POST['firstname'];
$last=$_POST['lastname'];
$kls=$_POST['kls'];
$email=$_POST['email'];
$pass=$_POST['password'];
$img=$_POST['image'];
	$syntax=mysql_query("update siswa set first_nm='$first', last_nm='$last', kls='$kls', email_sis='$email', pass_sis='$pass', img='$img' where email_sis='$user' and pass_sis='$pass'");
	?><script language="javascript">alert('SUKSES');
document.location='../editprofile.php'</script><?php 

}
?>